package com.ymttest.database.sqlwapper.sqdistributor;

import java.util.HashMap;
import java.util.List;

import com.ymt.database.SqlManager;
import com.ymttest.database.model.sqdistributor.ProductCommissionConfig;

public class ProductCommissionConfigWrapper {
	
	SqlManager manager;

	public ProductCommissionConfigWrapper() {
		manager = new SqlManager("sqdistributor");
	}

	@SuppressWarnings("unchecked")
	public ProductCommissionConfig selectByPrimaryKey(Long id) {

		ProductCommissionConfig productCommissionConfig = null;
		List<ProductCommissionConfig> result = manager
				.getSelectResults(
						"com.ymttest.database.mapping.sqdistributor.ProductCommissionConfigMapper.selectByPrimaryKey",
						id);
		manager.commit();

		if (result.size() > 0) {
			productCommissionConfig = result.get(0);
		}

		return productCommissionConfig;
	}
	
	@SuppressWarnings("unchecked")
	public ProductCommissionConfig selectByMerchantIdAndProductId(Long merchantId, String productId) {

		HashMap<String, Object> map = new HashMap<>();
		
		map.put("merchant_id", merchantId);
		map.put("product_id", productId);
		
		ProductCommissionConfig productCommissionConfig = null;
		List<ProductCommissionConfig> result = manager
				.getSelectResults(
						"com.ymttest.database.mapping.sqdistributor.ProductCommissionConfigMapper.selectByMerchantIdAndProductId",
						map);
		manager.commit();

		if (result.size() > 0) {
			productCommissionConfig = result.get(0);
		}

		return productCommissionConfig;
	}
	
	public static void main(String[] args) {
		
		ProductCommissionConfigWrapper test = new ProductCommissionConfigWrapper();

		System.out.println(test.selectByMerchantIdAndProductId(502053449L, "p5370062").getId());
	}
}
